package com.wenjie.controller;

import com.wenjie.original.entity.common.vo.RestBaseVo;
import com.wenjie.original.entity.vo.OrderBoxAuthority.OrderBoxAuthorityUpOrAddVo;
import com.wenjie.original.entity.vo.OrderBoxAuthority.OrderBoxAuthorityVo;
import com.wenjie.original.service.IOrderBoxAuthorityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api("打包计划的权限")
@RestController
@RequestMapping("/api/orderBoxAuthority")
public class OrderBoxAuthorityController {

    @Autowired
    private IOrderBoxAuthorityService orderBoxAuthorityService;

    @ApiOperation("查询接口")
    @PostMapping("/list")
    public RestBaseVo<OrderBoxAuthorityVo.ResVo> list(@RequestBody @Validated OrderBoxAuthorityVo.SelVo selVo) {
        return orderBoxAuthorityService.list(selVo, OrderBoxAuthorityVo.ResVo.class);
    }


    @ApiOperation("查询授权数据接口-查到当前用户授权全部的打包计划信息")
    @PostMapping("/selfList")
    public RestBaseVo<OrderBoxAuthorityVo.SelfResVo> slefList(@RequestBody @Validated OrderBoxAuthorityVo.SelfSelvo selvo) {
        return orderBoxAuthorityService.slefList(selvo);
    }


//    @ApiOperation("查询授权数据详情---查到当前用户授权的特定打包计划信息")
//    @PostMapping("/selfById")
//    public OrderBoxAuthorityVo.SelfResVo slefById(Long orderBoxId) {
//        return orderBoxAuthorityService.slefList(orderBoxId, null).getList().get(0);
//    }
//
//    @ApiOperation("查询授权数据详情---查到当前用户授权的特定打包计划信息")
//    @PostMapping("/selfBy")
//    public OrderBoxAuthorityVo.SelfResVo slefBySequence(Integer sequence) {
//        return orderBoxAuthorityService.slefList(null, sequence).getList().get(0);
//    }


    @ApiOperation("添加接口")
    @PostMapping("/add")
    public void add(@RequestBody @Validated OrderBoxAuthorityUpOrAddVo.AddVo addVo) {
        orderBoxAuthorityService.save(addVo);
    }

    @ApiOperation("修改接口")
    @PostMapping("/up")
    public void up(@RequestBody @Validated OrderBoxAuthorityUpOrAddVo.UpVo upVo) {
        orderBoxAuthorityService.updateById(upVo);
    }

    @ApiOperation("删除接口")
    @PostMapping("/del")
    public void del(@RequestBody @Validated Long id) {
        orderBoxAuthorityService.removeById(id);
    }


}
